<?php
/*
 * @Descripttion: 
 * @version: 
 * @Author: ewgof
 * @Date: 2020-08-11 23:38:43
 * @LastEditors: ewgof
 * @LastEditTime: 2020-10-25 15:23:48
 */
namespace cw\facade;

use cw\Facade;


class Cache extends Facade
{
    public static function __callStatic($action, $argv)
    {
        $driver = strtolower(config('cache.driver'));
        if (defined('CACHE_REGISTER')) {
            $cahce_driver = array_merge(CW_CACHE_REGISTER, CACHE_REGISTER);
        } else {
            $cahce_driver = CW_CACHE_REGISTER;
        }

        $class_name = $cahce_driver[$driver];
        
        if (in_array($action, ['clean'])) {
            return \call_user_func([new $class_name, $action]);
        }
        if (in_array($action, ['get', 'delete', 'pull'])) {
            return \call_user_func([new $class_name(@$argv[0]), $action], @$argv[0]);
        }
        if (\in_array($action, ['set'])) {
            return \call_user_func([new $class_name(@$argv[0]), $action], @$argv[0], @$argv[1], @$argv[2]);
        }
        if (in_array($action, ['inc', 'dec'])) {
            return \call_user_func([new $class_name(@$argv[0]), $action], @$argv[0], @$argv[1]);
        }
    }
}
